{include file="./headStart.tpl"}
<head>
<script type="text/javascript" src="./js/jquery.colorbox.js"></script>
<script type="text/javascript" src="./js/Modal.js"></script>
<link media="screen" rel="stylesheet" href="./css/colorbox.css" />
<link rel="stylesheet" type="text/css" href="./css/SModal.css">
{literal}
<script type="text/javascript">
$(document).ready(function() {
  $("#categoryId").focus();
  subCategoryCombo();
  subCatFilterCombo();

jQuery('.addCategary').colorbox({maxWidth: '75%', onComplete: function(){
  $("#categoryName").focus();
  jQuery("#categoryAdd").submit(function(){
  	var categoryNameVar = $("#categoryName").val();
    jQuery.post(
      jQuery(this).attr('action'),
      jQuery(this).serialize(),
      function(data){
      	$("<option value='"+data+"' SELECTED>"+categoryNameVar+"</option>").appendTo("#categoryId");
        $.colorbox.close();
        subCategoryCombo();
      }
    );
   return false;
 });
}});

jQuery('.addSubCategary').colorbox({maxWidth: '75%', onComplete: function(){
  $("#subCategoryName").focus();
  $('#categoryIdPopup').val($('#categoryId').val());
  jQuery("#subCategoryAdd").submit(function(){
  	var subCategoryNameVar = $("#subCategoryName").val();
    jQuery.post(
      jQuery(this).attr('action'),
      jQuery(this).serialize(),
      function(data){
        $.colorbox.close();
        subCategoryCombo();
        $("<option value='"+data+"' SELECTED>"+subCategoryNameVar+"</option>").appendTo("#subCategoryId");
      }
    );
   return false;
 });
}});

});

function subCategoryCombo()
{
  var dataString = "categoryId=" + $('#categoryId').val();
  $.ajax({
  	url: "./subCategoryAj.php",
  	cache: false,
  	data: dataString,
  	success:function(data){
  		$('#subCategoryComboSpan').html(data);
  		$('#categoryId').focus();
    }
  });
}
// Filter Data Listing : Starts
// Function on change of Category to get value of Sub-Category : Starts
function subCatFilterCombo()
{
  var dataString = "categoryId=" + $('#catFilterId').val();
  $.ajax({
  	url: "./subCatFilterAj.php",
  	cache: false,
  	data: dataString,
  	success:function(data){
  		$('#subCatFiltComboBox').html(data);
  		$('#subCatFiltId').focus();
    }
  });
  itemFilterCombo();
}
// Function on change of Category to get value of Sub-Category : Ends
// Function on change of Sub-Category to get value of Items : Starts
function itemFilterCombo()
{
  var dataString = "subCategoryId=" + $('#subCatFiltId').val() + "&categoryId=" + $("#catFilterId").val();
  $.ajax({
  	url: "./itemFilterAj.php",
  	cache: false,
  	data: dataString,
  	success:function(data){
  		$('#itemFiltId').html(data);
  		$('#itemFiltId').focus();
    }
  });
}
// Function on change of Sub-Category to get value of Items : Ends
// Function G O... Button :Starts
function getFilterData()
{
  var dataString = "itemId=" + $("#itemId").val() + "&subCategoryId=" + $("#subCatFiltId").val() + "&categoryId=" + $("#catFilterId").val();
  $.ajax({
    type: "GET",
    url:  "productFilterAj.php",
    data: dataString,
    success: function(data){ 
      $("#filteredData").html(data);
    }
  });
}
// Function G O... Button :Ends
// Filter Data Listing : Ends
function deletechecked()
{
	var answer = confirm("Delete Selected Recored ?")
	if (answer)
	{
	  document.messages.submit();
	}
	return false;
}
</script>
{/literal}
</head>
{include file="./headEnd.tpl"}
<form name="form" action="{$smarty.server.PHP_SELF}" id="form" method="post">
<input type="hidden" name="itemId" value="{$itemId}" />  
<table align="center" border="1" cellpadding="2" cellspacing="1" id="tableItem">
<tr>
  <td align="center" class="table1" colspan="2">Product Entry</td>
</tr>
<tr>
  <td align="right" class="table2">Category :</td>
  <td align="left" class="table2">
  	{if $isEdit != 1}
    <select name="categoryId" id="categoryId" class="categoryId" onchange="subCategoryCombo();">
      {html_options values=$categoryIdArr output=$categoryNameArr selected=$categorySelected}
    </select>
    <a href="categoryAdd.php" id="addCategary" class="addCategary">Add</a>
    {else}
      <input type="hidden" name="categoryId" value="{$categoryId}" />{$categoryName}
    {/if}
  </td>
</tr>
<tr>
  <td align="right" class="table2" >Sub Category :</td>
  <td align="left" class="table2">
  	{if $isEdit != 1}
      <span id="subCategoryComboSpan"></span>
      <a href="subCategoryAdd.php?categoryId="javascript: $('#categoryId').val();" id="addSubCategary" class="addSubCategary">Add</a>
    {else}
      <input type="hidden" name="subCategoryId" value="{$subCategoryId}" />{$subCategoryName}
    {/if}
  </td>
</tr>
<tr>
  <td align="right" class="table2">Product Name :</td>
  <td class="table2"><input type="text" name="itemName" id="itemName" value="{$itemName}" size="100"></td>
</tr>
<tr>
  <td align="right" class="table2">Product Make :</td>
  <td class="table2"><input type="text" name="itemMake" id="itemMake" value="{$itemMake}" size="100"></td>
</tr>
<tr>
  <td align="right" class="table2">Product Model No. :</td>
  <td class="table2"><input type="text" name="modelNo" id="modelNo" value="{$modelNo}" size="100"></td>
</tr>
<tr>
  <td align="right" class="table2">Current Stock :</td>
  <td class="table2"><input type="text" name="currentStock" id="currentStock" value="{$currentStock}"></td>
</tr>
<tr>
  <td align="right" class="table2">Max Level :</td>
  <td class="table2"><input type="text" name="maxLevel" id="maxLevel" value="{$maxLevel}"></td>
</tr>
<tr>
  <td align="right" class="table2">Min Level :</td>
  <td class="table2"><input type="text" name="minLevel" id="minLevel" value="{$minLevel}"></td>
</tr>
<tr>     
  <td class="table2" align="center" colspan="2">
    <input class="button" type="submit" name="insertBtn" value="Submit" class="insertBtn" />
    {if $itemId > 0}
      <input class="button" type="submit" name="cancelBtn" value="Cancel" />
    {/if}
  </td>
</tr>  
</table>
</form> 

<table border='0' cellpadding='1' cellspacing='2' align='center'>
<tr>
  <td class="table1" align="center" colspan="11"><font style="font-size: 16px"><b> Product Available </b></font></td>
</tr>
<tr>
  <td align='left'>Category :
    <select name="catFilterId" id="catFilterId" class="catFilterId" onchange="subCatFilterCombo();">
    	<option>All</option>
      {html_options values=$categoryIdArr output=$categoryNameArr}
    </select>
 	</td>
	<td align='left'>
  	SubCategory :<span id="subCatFiltComboBox"></span><br/>
 	</td>
 	<td align='left'>
  	Product :<span id="itemFiltId"></span>
 	</td>
 	 <td valign="bottom" >
    <input type="button" name="button" id="goButton" value=" G O... " class="button" onclick="getFilterData();" />
  </td>
</tr>
</table>
<div id="filteredData">
</div>
{include file="footer.tpl"}